package com.cw.controller;

import com.cw.common.api.ResultObject;
import com.cw.common.constant.Response;
import com.cw.dto.DayConfigurationDto;
import com.cw.dto.WeekAppointmentDto;
import com.cw.service.DayConfigurationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = {"日间病房/输注配置"})
@RestController
@RequestMapping("/DayConfiguration")
public class DayConfigurationController {

    @Autowired
    private DayConfigurationService targetService;

    @PostMapping("/save")
    @ApiOperation("保存日间配置")
    public ResultObject save(@RequestBody DayConfigurationDto dayConfigurationDto){
        Response result = targetService.saveBatch(dayConfigurationDto);
        return ResultObject.resultReturn(result);
    }

    @PostMapping("/updateRJSet/{type}")
    @ApiOperation("更新日间配置")
    public ResultObject update(@RequestBody List<WeekAppointmentDto> weekAppointmentDto, @PathVariable Integer type){
        return ResultObject.successReturn(targetService.updateBatch(weekAppointmentDto,type));
    }

    @ApiOperation("回显数量")
    @GetMapping("/getMaxCount")
    public ResultObject getMaxCount(@RequestParam String type){
        return ResultObject.successReturn(targetService.getMaxCount(type));
    }

    @ApiOperation("回显页面信息")
    @GetMapping("/getAllInfo")
    public ResultObject getAllInfo(Integer type){
        return ResultObject.successReturn(targetService.getAllInfo(type));
    }


}
